﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
using System.Threading;

namespace IGolovkine.AoA.Tests
{
    [TestClass]
    public class AsyncStreamTests
    {
        [TestMethod]
        public void Spec()
        {

            TestPacket request = new TestPacket("Hello world!");
            MemoryStream memStream = new MemoryStream(request.Data);
            
            AsyncStream stream = new AsyncStream(memStream, 2);
            List<byte> buffer = new List<byte>();
            
            stream.Output.Subscribe(b =>
                {
                    lock (buffer)
                    {
                        buffer.AddRange(b);
                    }
                });

            Thread.Sleep(1000);

            Assert.AreEqual(request, new TestPacket(buffer));
            TestPacket reply = new TestPacket(10);

        }
    }
}
